home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
extras
/
programm
/
gemfsc20
/
gemfsc20.lzh
/
GEMFUNCS
/
OBJRBUTL.C
< prev
next >
Wrap
C/C++ Source or Header
|
1992-11-03
|
2KB
|
75 lines
/**************************************************************************
* OBJRBUTL.C - Functions for working with radio buttons.
*************************************************************************/
#include "gemfintl.h"
/*-------------------------------------------------------------------------
* obj_rbfind - Extended radio button finder.
*-----------------------------------------------------------------------*/
short obj_rbfind(tree, parent, rbstate)
register OBJECT *tree;
register short parent;
register short rbstate;
{
register short kid;
register OBJECT *pobj;
kid = tree[parent].ob_head;
while ( (kid != parent) && (kid >= R_TREE) ) {
pobj = &tree[kid];
if ((pobj->ob_flags & RBUTTON) && (pobj->ob_state & rbstate)) {
return kid;
}
kid = pobj->ob_next;
}
return NO_OBJECT;
}
/*-------------------------------------------------------------------------
* obj_parent - Find the parent of a given child object.
*-----------------------------------------------------------------------*/
short obj_parent(tree, curobj)
register OBJECT *tree;
register short curobj;
{
register short nxtobj;
if (curobj == R_TREE) /* The root of a tree has no parent */
return R_TREE;
for (;;) {
nxtobj = tree[curobj].ob_next;
if (tree[nxtobj].ob_tail == curobj)
return nxtobj;
curobj = nxtobj;
}
}
/*-------------------------------------------------------------------------
* obj_rbselect - Set a radio button to SELECTED, de-sel others in the group.
*-----------------------------------------------------------------------*/
short obj_rbselect(ptree, selobj, state)
register OBJECT *ptree;
register short selobj;
register short state;
{
register short oldobj;
if (selobj <= R_TREE) {
return NO_OBJECT;
}
oldobj = obj_rbfind(ptree, obj_parent(ptree, selobj), state);
if (oldobj != NO_OBJECT) {
ptree[oldobj].ob_state &= ~state;
}
ptree[selobj].ob_state |= state;
return oldobj;
}